home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1998 Special
/
special1988a.d64
/
math dungeon
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
10KB
|
295 lines
110 dim cm$(22),cm(22),in$(5),in(5),ob$(13),ob(13),ds$(40),fl(10,10)
120 sys65517:cc=peek(781)
130 ifcc=40thenpoke53281,1
150 gosub 700:gosub1620
155 print"[147]"
160 gosub790:cm(2)=1:cm(5)=1:fori=14to19:cm(i)=1:next:ob(1)=1
170 pr$=ds$(1):gosub2570:ifgtthenpr$=ds$(2):gosub2570
180 ifgt=0thenpr$=ds$(3):gosub2570
190 gosub2310:ifpl=2orpl=5thengosub800:goto190
200 ifpl=16andgt=0thenpr$=ds$(3):gosub2570:goto190
210 ifpl=16then280
220 ifpl>16thengoto250
230 goto170
240 print"[147]":pr$=ds$(4):gosub2570
250 gosub790:fori=14to19:cm(i)=1:next:gosub2310:ifpl=16then280
260 ifpl=15thenpr$=ds$(4):gosub2570
270 goto250
280 gosub790:print"[147]":cm(1)=1:cm(3)=1:cm(6)=1:fori=14to19:cm(i)=1:next
290 cm(4)=1
300 pr$=ds$(5):gosub2570:ifmb=0thenpr$=ds$(6):gosub2570
310 ifmbthenpr$=ds$(7):cm(7)=1:gosub2570:ifnt=1thenpr$=ds$(11):gosub 2570
320 iffd=0thenpr$=ds$(8):nt=1:gosub2570
330 iffdthenpr$=ds$(9):nt=0:gosub2570
340 gosub2310:ifpl=15then300
350 if(pl=18)or(pl=19)thengoto300
360 ifpl=17thengoto160
370 if(pl=16)and(fd=0)then320
380 ifpl=16andfd=0then320
390 ifpl=16then450
400 ifpl=1thenpr$=ds$(10):gosub2570
410 if(pl=3)or(pl=6)thengosub900:goto340
415 ifpl=7andnt=0thenprint"i see no note here!":goto340
420 ifpl<>7then340
430 pr$="there is a question on the note.":gosub2570
435 gosub1320:ifwr=1thengoto160
440 pr$=ds$(12):gosub2570:pr$=ds$(13):gosub2570:fd=1:mb=0:goto340
450 gosub790:print"[147]";
470 pr$="a trap door opens beneath your feet and you begin sliding down a "
480 pr$=pr$+"chute. you pass a neon sign that says :":gosub2570:print
490 ifcc=40then505
500 print" 'math dungeon'":print:print" 'level "+str$(lv)+"'"
501 print:print:goto510
505 print" 'math dungeon'"
506 print:print" 'level "+str$(lv)+"'"
510 pr$="press any key to continue":gosub2570:print:print
520 geta$:ifa$=""then520
530 lt=1:px=int(rnd(1)*10)+1:py=int(rnd(1)*10)+1:fl(py,px)=2
540 gosub790:cm(9)=1:fori=12to19:cm(i)=1:next:cm(9)=lt:cm(22)=1
550 iffl(py,px)=2thenprint"[147]":pr$=ds$(14):gosub2570
560 iffl(py,px)=1thenprint"[147]":pr$=ds$(15):gosub2570
570 iflt=1thenpr$=ds$(16):gosub2570
580 gosub2310
590 ifpl=9thengosub950:goto580
600 ifpl=12thengosub970:goto580
610 ifpl=13thengosub1000:goto580
620 ifpl=15andlo=0then550
630 ifpl=15andlo=1thengosub1020:goto570
640 ifpl=14then580
650 ifpl=22thengosub2470:goto670
660 ifpl>15thengosub1560:if(lo=0)or(wa=1)then580
670 onzgosub1860,1860,2000
680 goto670
690 end
700 print"[147]":ifcc=40thenprinttab(10);:goto720
710 printtab(1);
720 print" math dungeon ":print"":ifcc=40thenprinttab(12);:goto740
730 printtab(3);
740 print"a math adventure"
750 print"":ifcc=40then755
751 print" enter desired level(1-5)";:goto760
755 print" enter desired level(1-5)";
760 inputlv:iflv<1orlv>5thengoto750
770 fori=1to22:readcm$(i):next:fori=1to5:readin$(i):next
780 fori=1to29:readds$(i):next:return
790 fori=1to22:cm(i)=0:nexti:ifin(5)=1thencm(20)=1:return
800 ifpl=2andgt=1thenpr$="the gate is already open.":gosub2570
810 ifpl=2andgt=0thengt=1:print"ok."
820 ifpl=5andgt=0thenpr$="the gate is already closed.":gosub2570
830 ifpl=5andgt=1thengt=0:print"ok."
840 return
850 ifpl=1andfd=1thenpr$="the door is already open.":gosub2570
860 ifpl=1andfd=0thenfd=1:print"ok."
870 ifpl=4andfd=0thenpr$="the door is already closed.":gosub2570
880 ifpl=4andfd=1thenfd=0:print"ok."
890 return
900 ifpl=3andmb=1thenpr$="the milkbox is already open.":gosub2570
910 ifpl=3andmb=0thenmb=1:print"ok.":cm(7)=1
920 ifpl=6andmb=0thenpr$="the milkbox is already closed.":gosub2570
930 ifpl=6andmb=1thenmb=0:print"ok.":cm(7)=0
940 return
950 ifin(1)=1thenpr$="you already have the light.":gosub2570:return
960 iflt=1thenlt=0:in(1)=1:print"ok.":cm(9)=0:return
970 ifin(1)=0thenpr$="you do not have a light.":gosub2570:return
980 iflo=0thenprint"ok.":lo=1:return
990 iflo=1thenpr$="the light is already on.":gosub2570:return
1000 iflo=0thenpr$="the light is already off.":gosub2570:return
1010 iflo=1thenprint"ok.":lo=0:return
1020 print"[147]"ds$(16-fl(py,px))
1030 ec=px+1:dn$="east":ifec=11thengoto1050
1040 iffl(py,ec)<>0thengosub1120
1050 wc=px-1:dn$="west":ifwc=0thengoto1070
1060 iffl(py,wc)<>0thengosub1120
1070 nc=py-1:dn$="north":ifnc=0thengoto1090
1080 iffl(nc,px)<>0thengosub1120
1090 sc=py+1:dn$="south":ifsc=11thengoto1110
1100 iffl(sc,px)<>0thengosub1120
1110 return
1120 printdn$" is a doorway.":return
1130 ifgk=0andbk=0andrk=0thenprint"what key?":return
1140 print"ok."
1150 ifgkthengk=0:in(2)=1:return
1160 ifbkthenbk=0:in(3)=1:return
1170 ifrkthenrk=0:in(4)=1:bd=2:return
1180 return
1190 ifgd<>1then1220
1200 ifin(2)=0thenpr$=ds$(10):gosub2570:return
1210 ifin(2)=1thenpr$=ds$(27):gosub2570:ma=1:cm(11)=1:cm(1)=0:return
1220 ifbd<>1then1250
1230 ifin(3)=0thenpr$=ds$(10):gosub2570:return
1240 ifin(3)=1thenpr$=ds$(28):gosub2570:cm(8)=1:rk=1:cm(1)=0:return
1250 ifrd<>1then1280
1260 ifin(4)=0thenpr$=ds$(10):gosub2570:return
1270 ifin(4)=1thenprint"[147]":pr$=ds$(29):gosub2570:gosub2520
1280 return
1290 g=int(rnd(1)*lv*10)+1:pr$="you have found "+str$(g)+" gold pieces."
1300 gosub2570:gp=gp+g:pr$="you now have "+str$(gp)+" gold pieces.":gosub2570
1310 cm(10)=0:return
1320 op=int(rnd(1)*4)+1
1340 if(lv<=2)and(op>=3)then1320
1350 print"what is...";
1360 onopgoto1370,1400,1430,1460
1370 x=int(rnd(1)*lv*10):y=int(rnd(1)*lv*10)
1380 iflv>4thenx=x-int(rnd(1)*lv*5):y=y-int(rnd(1)*lv*5)
1390 z1=x+y:printx" + "y"?":inputz$:gosub1510:ifwr=2then1390
1395 return
1400 x=int(rnd(1)*lv*10):y=int(rnd(1)*lv*10)
1410 iflv<=3thenify>xthent=x:x=y:y=t
1420 z1=x-y:printx" - "y"?":inputz$:gosub1510:ifwr=2then1420
1425 return
1430 x=int(rnd(1)*lv*5):y=int(rnd(1)*lv*5)
1440 iflv>=4thenx=x-int(rnd(1)*lv*2):y=y-int(rnd(1)*lv*2)
1450 z1=x*y:printx" * "y"?":inputz$:gosub1510:ifwr=2then1450
1455 return
1460 x=int(rnd(1)*lv*5):y=int(rnd(1)*lv*5)
1470 iflv>=4thenx=x-int(rnd(1)*lv*3):y=y-int(rnd(1)*lv*3)
1480 ify=0theny=1
1490 z1=x/y:ifz1<>int(z1)then1460
1500 printx" / "y"?":inputz$
1505 gosub1510:ifwr=2then1490
1506 return
1510 ifval(z$)<>0thenz2=val(z$):goto1540
1520 ifz$<>"0"thenpr$="answer the question first!":gosub2570:wr=2:return
1530 z2=val(z$)
1540 ifz1=z2thenprint"[147]correct!!":wr=0:return
1550 print"[147]incorrect!!":wr=1:return
1560 wa=0:iflo=0thenpr$="i'd turn on my light first.":gosub2570:goto1610
1570 c=abs(pl=18)-abs(pl=19):d=abs(pl=17)-abs(pl=16):tx=px+c:ty=py+d
1580 iftx=11ortx=0orty=11orty=0thenprint"there is a wall there.":wa=1:goto1610
1590 iffl(ty,tx)=0thenprint"there is a wall there.":wa=1:goto1610
1600 px=tx:py=ty
1610 z=fl(py,px):return
1620 fori=1to10:forj=1to10:fl(i,j)=0:nextj:nexti
1625 nm=int(rnd(1)*10)+lv:i=1
1630 x=int(rnd(1)*10)+1:y=int(rnd(1)*10)+1:iffl(y,x)=3then1630
1640 fl(y,x)=3:i=i+1:ifi<=nmthen1630
1650 fori=1tonm*2
1660 x=int(rnd(1)*10)+1:y=int(rnd(1)*10)+1
1670 iffl(y,x)=3then1660
1680 fl(y,x)=0:nexti
1690 fori=1to10:forj=1to10
1700 iffl(i,j)=3thengosub1780
1710 nextj:nexti
1720 gosub1840:gx=x:gy=y:if(bx=xandby=y)or(rx=xandry=y)orfl(y,x)=0then1720
1730 gosub1840:bx=x:by=y:if(gx=xandgy=y)or(rx=xandry=y)orfl(y,x)=0then1730
1740 gosub1840:x1=x:y1=y:if(x2=xandy2=y)or(x3=xandy3=y)orfl(y,x)=0then1740
1750 gosub1840:x2=x:y2=y:if(x1=xandy1=y)or(x3=xandy3=y)orfl(y,x)=0then1750
1760 gosub1840:x3=x:y3=y:if(x1=xandy1=y)or(x2=xandy2=y)orfl(y,x)=0then1760
1770 return
1780 fork=jto10:gosub1800:nextk:fork=jto1step-1:gosub1800:nextk
1790 fork=ito10:gosub1820:nextk:fork=ito1step-1:gosub1820:nextk:return
1800 iffl(i,k)=0thenfl(i,k)=int(rnd(1)*2)+1
1810 return
1820 iffl(k,j)=0thenfl(k,j)=int(rnd(1)*2)+1
1830 return
1840 x=int(rnd(1)*10)+1:y=int(rnd(1)*10)+1:iffl(y,x)=0then1840
1850 return
1860 gosub790:fori=12to19:cm(i)=1:next:cm(22)=1
1870 print"[147]":pr$=ds$(16-z):gosub2570:iflo=1thengosub1030
1880 gosub2270:gosub2200
1890 gosub2310:ifpl=15andlothengosub1020:goto1880
1900 ifpl=20thengosub2850:goto1890
1910 ifpl=15andlo=0then1870
1920 ifpl=1thengosub1190:goto1890
1930 ifpl=14then1890
1940 ifpl=11thengosub2490:goto1890
1950 ifpl=8thengosub1130:goto1890
1960 ifpl=22thengosub2470:return
1970 ifpl>15thengosub1560:if(lo=0)or(wa=1)then1890
1980 return
2000 gosub790:fori=10to19:cm(i)=1:nexti:cm(22)=1
2010 pr$=ds$(23):gosub2570:pr$=ds$(24):gosub2570:gosub1320:ifwr=0thengoto2050
2020 gp=0:pr$=ds$(25):gosub2570:forw=1to2000:nextw
2030 x=int(rnd(1)*10+1):y=int(rnd(1)*10)+1:iffl(y,x)=0then2030
2040 px=x:py=y:z=fl(py,px):return
2050 pr$=ds$(26):gosub2570:fl(py,px)=2
2060 pr$=ds$(14):gosub2570:iflothengosub1030
2070 gosub2270:gosub2200
2080 gosub2310
2090 ifpl=20thengosub2850:goto2080
2100 ifpl=15andlothengosub1020:goto2070
2110 ifpl=15andlo=0then2060
2120 ifpl=14then2080
2130 ifpl=11then2490:goto2080
2140 ifpl=8thengosub1130:goto2080
2150 ifpl=1thengosub1190:goto2080
2160 ifpl=10thengosub1290:goto2080
2170 ifpl=22thengosub2470:return
2180 ifpl>15thengosub1560:if(lo=0)or(wa=1)then2080
2190 return
2200 if(x1=pxandy1=py)andgd<>2thenpr$=ds$(17):gosub2570:gd=1:cm(1)=1
2210 if(x2=pxandy2=py)andbd<>2thenpr$=ds$(19):gosub2570:bd=1:cm(1)=1
2220 if(x3=pxandy3=py)andrd<>2thenpr$=ds$(18):gosub2570:rd=1:cm(1)=1
2230 if(x1<>pxory1<>py)andgd<>2thengd=0
2240 if(x2<>pxory2<>py)andbd<>2thenbd=0
2250 if(x3<>pxory3<>py)andrd<>2thenrd=0
2260 return
2270 ifbx=pxandby=pyandin(3)=0thenpr$=ds$(21):gosub2570:bk=1:cm(8)=1
2280 ifgx=pxandgy=pyandin(2)=0thenpr$=ds$(20):gosub2570:gk=1:cm(8)=1
2290 ifrx=pxandry=pyandin(4)=0thenpr$=ds$(22):gosub2570:rk=1:cm(8)=1
2300 return
2310 inputc$:pl=0:fori=1to22:ifcm$(i)=c$thenpl=i:i=23
2320 next
2330 ifpl=0thenprint"you can't do that!":goto2310
2340 n$="":i=1
2350 t$=mid$(c$,i,1)
2360 ifasc(t$)=32thenl=i:goto2390
2370 ifi=len(c$)thengoto2410
2380 i=i+1:goto2350
2390 n$=mid$(c$,l+1,len(c$))
2400 ifcm(pl)=0thenprint"i see no "n$" here!":goto2310
2410 ifc$="inv"thengoto2430
2420 return
2430 print"you are carrying :"
2440 fori=1to5:ifin(i)=1thenprint"a "in$(i)
2450 nexti:ifgp<>0thenprintgp" gold pieces."
2460 return
2470 px=int(rnd(1)*10)+1:py=int(rnd(1)*10)+1:iffl(py,px)=0then2470
2480 z=fl(py,px):return
2490 ifin(5)=1thenpr$="you already have the map!":gosub2570:return
2500 ifma=0thenprint"what map?":return
2510 print"ok.":in(5)=1:ma=0:cm(20)=1:gd=2:return
2520 pr$="you have found your way out of the math dungeon.":gosub2570
2530 pr$=" you have won "+str$(gp)+" gold pieces in your journey.":gosub2570
2540 print" play again";:input a$
2550 ifa$="y"thenrun
2560 end
2570 iflen(pr$)<=ccthenprintpr$:return
2580 t$=mid$(pr$,cc,1):ifasc(t$)=32theni=cc:goto2620
2590 i=cc-1
2600 t$=mid$(pr$,i,1):ifasc(t$)=32thengoto2620
2610 i=i-1:goto2600
2620 a$=mid$(pr$,i+1,len(pr$)):b$=mid$(pr$,1,i-1):printb$
2630 iflen(a$)<=ccthenprinta$:return
2640 pr$=a$:goto2570
2650 dataopen door,open gate,open milkbox,close door,close gate,close milkbox
2660 dataget note,get key,get light,get gold,get map,light on,light off,inv
2670 datalook,n,s,e,w,map,map,algebra,light,green key,blue key,red key,map
2680 datayou are facing north. a gate is in front of you.,the gate is open.
2690 datathe gate is closed.,you are in a dense forest.
2700 datayou are in front of an old house. there is a milkbox by the door.
2710 datathe milkbox is closed.,the milkbox is open.,the door is closed.
2720 datathe door is open.,the door is locked. you do not have the right key.
2730 datathere is a note in the milkbox.,the door flies open with a bang!
2740 datathe note disappears and the milkbox closes.
2750 datayou are in a cold and damp room.,you are in a long and narrow hallway.
2760 datathere is an unlit light here.,there is a green door here.
2770 datathere is a red door here.,there is a blue door here.
2780 datathere is a green key here.,there is a blue key here.
2790 datathere is a red key here.,before you can get a good look at the area..
2800 dataa monster jumps out and says 'you must answer this question!
2810 data'now i'll take all your gold and transport you away!
2820 datathe monster disappears. you see some gold here!
2830 datathere is a map here!,there is a red key here!
2840 datathere is a sudden flash and you find yourself amidst some trees.
2850 ifin(5)=0thenprint"you don't have a map!":return
2860 print"[147]":print
2870 fori=1to10:tb=1:forj=1to10
2880 ifi=pyandj=pxthenprinttab(tb)"*";:goto2930
2890 iffl(i,j)=3thenprinttab(tb)"[144]m";:goto2930
2900 iffl(i,j)=2thenprinttab(tb)"r";:goto2930
2910 iffl(i,j)=1thenprinttab(tb)"[156]h";:goto2930
2920 printtab(tb)"[158] [146]";
2930 tb=tb+2:nextj:print:print:nexti
2940 print"":return